<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/pagetag.tld" prefix="page" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
    <title>菜单管理</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css"
          href="<%=request.getContextPath()%>/resources/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css"
          href="<%=request.getContextPath()%>/resources/css/style.css"/>
    <script type="text/javascript"
            src="<%=request.getContextPath()%>/resources/js/jquery.js"></script>
</head>
<body>
<form class="form-inline definewidth m20" action="list.do" method="post">
    菜单名称：
    <input type="text" name="menuName" id="menuName" class="abc input-default" placeholder=""
           value="">&nbsp;&nbsp;
    <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
    <button type="button" class="btn btn-success" id="addnew">新增</button>
</form>
<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
        <th>菜单名称</th>
        <th>菜单URL</th>
        <th>菜单序号</th>
        <th>管理操作</th>
    </tr>
    </thead>
    <c:forEach var="menuMap" items="${menuMap}">
        <tr id="tr_${menuMap.key.id}">
            <td colspan="3">${menuMap.key.menuName}</td>
            <td><a href="redirect.do?type=update&id=${menuMap.key.id}">编辑</a>&nbsp;&nbsp;
                <a href="javascript:del(${menuMap.key.id})">删除</a></td>
        </tr>
        <c:forEach var="menu" items="${menuMap.value}">
            <tr id="tr_${menu.id}">
                <td>${menu.menuName}</td>
                <td>${menu.menuUrl}</td>
                <td>${menu.menuOrder}</td>
                <td><a href="redirect.do?type=update&id=${menu.id}">编辑</a>&nbsp;&nbsp;
                    <a href="javascript:del(${menu.id})">删除</a>
                </td>
            </tr>
        </c:forEach>
    </c:forEach>
</table>
</body>
</html>
<script>
    $(function () {
        $('#addnew').click(function () {
            window.location.href = "redirect.do?type=save";
        });
    });

    function del(id) {
        if (confirm("确定删除?")) {
            window.location.href = "delete.do?id=" + id;
        }
    }
</script>
